﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Docking2010.Views.Widget;
using DevExpress.XtraEditors;

namespace TS_XY_Train_Repaire.Temp
{
    public partial class XtraForm1 : Form
    {
        public XtraForm1()
        {
            InitializeComponent();
        }
        WidgetView view;
        StackGroup group1, group2, group3;
        void AddDocumentManager()
        {
            DocumentManager dM = new DocumentManager();
            view = new WidgetView();
            dM.View = view;
            view.QueryControl += widgetView1_QueryControl;
            view.AllowDocumentStateChangeAnimation = DevExpress.Utils.DefaultBoolean.True;
            group1 = new StackGroup();
            group2 = new StackGroup();
            group3 = new StackGroup();
            group1.Length.UnitType = LengthUnitType.Star;
            group1.Length.UnitValue = 2;
            view.StackGroups.AddRange(new StackGroup[] { group1, group2, group3});
            dM.ContainerControl = this;
        }
        int count = 1;

        private void XtraForm1_Load(object sender, EventArgs e)
        {
            //AddDocumentManager();
            //for (int i = 0; i < 5; i++)
            //{
            //    AddDocuments();
            //}
            ////Adding Documents to group1 is not necessary, since all newly created Documents are automatically placed in the first StackGroup.
            //group1.Items.AddRange(new Document[] { view.Documents[0] as Document, view.Documents[1] as Document });
            //view.Controller.Dock(view.Documents[2] as Document, group2);
            //view.Controller.Dock(view.Documents[3] as Document, group3);
        }

        void AddDocuments()
        {
            Document document = view.AddDocument("Document " + count.ToString(), "ucPreview") as Document;
            view.AddDocument(new ucPreview());
            document.MaximizedControl = new ucMaximizedContent();
            count++;
        }
        private void widgetView1_QueryControl(object sender, DevExpress.XtraBars.Docking2010.Views.QueryControlEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Document.ControlTypeName))
                e.Control = Activator.CreateInstance(Type.GetType(e.Document.ControlTypeName)) as Control;
            else
                e.Control = new Control();
        }
    }
}